using System;
using System.Linq;
using Precio.Logging.Facade.Context;

namespace Kaskelot.Services.Model
{
	public partial class PersonHandelseLogg : IEntity
	{
		public void OnBeforeCreate(KaskelotEntities ctx)
		{
			var person = ctx.Person.Where(p => p.Id == this.PersonId && p.ValId == this.ValId).FirstOrDefault();
			if (person != null)
			{
				person.AndradAv = LoggingCallContext.GetOriginalCaller();
				person.Andrad = DateTime.Now;
			}
		}

		public void OnBeforeUpdate()
		{
			this.Andrad = DateTime.Now;
		}
	}
}
